@extends('layouts.header')
@section('title','修改短信签名')
@section('content')
    <article class="page-container">
        <form class="form form-horizontal" id="myform" autocomplete="off">
            <div class="row cl c-red">
                <label class="form-label col-xs-3">错误提示：</label>
                <div class="formControls col-xs-9">
                    {{$data->back->Reason}}
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3">申请人：</label>
                <div class="formControls col-xs-9">
                    {{auth('admin')->user()->realname}}
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3">申请签名：</label>
                <div class="formControls col-xs-9">
                    <input type="text" readonly class="input-text" name="name" value="{{$data->name}}" style="border: none;">
                    <br>
                    <small>注意：签名由中英文，数字组成，不支持繁体字、符号、空格或全数字；建议申请实际产品或企业名称做为签名</small>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3 c-red">申请说明：</label>
                <div class="formControls col-xs-9">
                    <textarea cols="" rows="" class="textarea required" name="remark" id="remark" placeholder="描述使用场景&#10;域名&#10;临时访问的账号、密码&#10;长度不超过200个字符。">{{$data->remark}}</textarea>
                </div>
            </div>

            @csrf

            <div class="row cl pt-20">
                <div class="col-xs-9 col-xs-offset-3">
                    <a class="btn btn-primary radius" id="submit"> 提交 </a>
                    <a class="btn btn-primary radius" id="del"> 删除 </a>
                    <input class="btn btn-danger radius ml-15" type="button" value="取消" onclick="layer_close();">
                </div>
            </div>
        </form>
    </article>

    <script type="text/javascript">
        $(function () {
            $('input[name=price]').on('change', function () {
                let price = $(this).val();
                $('input[name=sms_num]').val(Math.ceil(price * 100 / 7));
            })
            $('#submit').on('click', function () {
                if ($('#myform').valid()) {
                    let oData = {
                        param: $('#myform').serializeArray()
                    }
                    ajax('post', '', oData);
                }
            })
            $('#del').on('click', function () {
                let id = {{request()->id}};
                layer.confirm('确认要删除吗？', {title: '询问', icon: 3}, function (index) {
                    ajax('get', '/'+adminName + '/notice/sms/sign/del/' + id, {}, delback);
                });

                function delback(res) {
                    layer.msg(res.msg, {icon: res.code, time: 2000});
                    if (res.code == 1) {
                        layer_close();
                    }
                }
            })
        });
    </script>
@endsection
